package com.yh.web;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yh.pojo.SysLog;
import com.yh.service.SysLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/syslog")
public class SysLogController {
    @Autowired
    private SysLogService sysLogService;

    @GetMapping("findAll")
    public String findAll(@RequestParam(value = "page", defaultValue = "1") Integer page,
                          @RequestParam(value = "size", defaultValue = "5") Integer size, Model model) {
        PageHelper.startPage(page, size);
        List<SysLog> sysLogList = sysLogService.findAllSysLog();
        PageInfo<SysLog> pageInfo = new PageInfo<>(sysLogList);
        model.addAttribute("pageInfo", pageInfo);
        //sysLogList
        model.addAttribute("sysLogList", sysLogList);
        return "syslog-list";
    }
}